﻿@using Devonline.Identity.Admin
@inject AdminSetting _adminSetting;
@{
    ViewData["Title"] = "用户管理";
    var defaultPassword = _adminSetting.DefaultPassword;
}
@model LoginViewModel
<div class="panel panel-default">
    <div class="form-content">
        <div class="form-body">
            <div class="row" id="filter" data-toggle="form" data-field="User" data-grid="#grid" data-filterable="true">
                <input data-field="name,userName" placeholder="请输入 姓名/用户名 模糊查询" data-size="4,0,12" data-logic="or" data-operator="contains" />
                <button data-button="query">查询</button>
                <button data-button="clear">清除条件</button>
                <div class="pull-right" style="padding-right:15px;">
                    <button data-button="add" data-popup="Edit">新 增</button>
                </div>
            </div>
            <div id="grid" data-toggle="grid" data-form="#filter" node="grid" data-content-popup="false" data-related="#_PopupDetail">
                <div node="columns" node-type="array">
                    <span data-field="image" data-title="用户图片" data-type="image" data-hidden="true"></span>
                    <span data-field="userName" data-title="用户名"></span>
                    <span data-field="name" data-title="用户姓名"></span>
                    <span data-field="alias" data-title="昵称/别名"></span>
                    <span data-field="type" data-title="用户类型" data-data-from="cache.authorizeType"></span>
                    <span data-field="group.name" data-title="直属单位"></span>
                    <span data-field="phoneNumber" data-title="手机号码"></span>
                    <span data-field="phoneNumberConfirmed" data-title="已确认" data-data-from="cache.yesOrNo"></span>
                    <span data-field="email" data-title="邮箱" data-hidden="true"></span>
                    @* <span data-field="lockoutEnabled" data-title="启用锁定" data-data-from="cache.yesOrNo"></span> *@
                    <span data-field="lockoutEnd" data-title="锁定结束时间" data-type="datetime"></span>
                    <span data-field="description" data-title="备注说明"></span>
                    <span data-field="state" data-title="状态" data-data-from="cache.dataState" data-hidden="true"></span>
                    <span data-field="createdOn" data-title="创建时间" data-type="datetime" data-hidden="true"></span>
                </div>
                <span node="dataSource">
                    <span node="transport">
                        <span node="read" data-url="/api/Users?$select=id,name,groupId,userName,alias,type,image,phoneNumber,email,state,createdOn,description&$expand=group($select=id,name)">
                        </span>
                    </span>
                    <span node="sort" data-field="userName" data-dir="asc"></span>
                </span>
            </div>
        </div>
    </div>
</div>

<div id="_PopupDetail" data-toggle="popup" data-type="Detail" data-title="用户信息" data-related="#filter">
    <div class="popup-content" data-toggle="form" data-field="User" data-url="/api/Users" data-detailable="true" data-size="12,4,8">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <div data-field="image" data-title="用户图片" data-type="img" data-with-attachments="true" data-business-type="User.Image" data-single="true"></div>
                    <span data-field="userName" data-title="用户名"></span>
                    <span data-field="name" data-title="用户姓名"></span>
                    <span data-field="alias" data-title="用户别名"></span>
                    <span data-field="type" data-title="用户类型" data-data-from="cache.authorizeType"></span>
                    <span data-field="group.name" data-title="直属单位"></span>
                    <span data-field="phoneNumber" data-title="手机号码"></span>
                    <span data-field="phoneNumberConfirmed" data-title="手机号码已确认" data-data-from="cache.yesOrNo"></span>
                    <span data-field="email" data-title="电子邮件"></span>
                    <span data-field="lockoutEnd" data-title="锁定结束时间" data-data-type="datetime"></span>
                    <span data-field="state" data-title="状态" data-data-from="cache.dataState"></span>
                    <span data-field="description" data-title="备注说明"></span>
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="edit" data-popup="Edit"></button>
            <button data-button="delete"></button>
            <button data-button="close"></button>
        </div>
    </div>
</div>

<div id="_PopupEdit" data-toggle="popup" data-type="Edit" data-title="用户信息" data-related="#filter" data-size="large" data-opened="#:Common.onUserEditOpened">
    <div class="popup-content" data-toggle="form" data-field="User" data-editable="true" data-url="/api/Users" data-size="12,3,7">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <input data-field="userName" data-title="用户名" required />
                    <input data-field="name" data-title="用户姓名" required />
                    <input data-field="alias" data-title="用户别名" />
                    <span data-field="type" data-title="用户类型" required type="radio" data-with-group="true" data-data="#:cache.authorizeType" data-value="Internal"></span>
                    <input data-field="phoneNumber" data-title="手机号码" required />
                    <input data-field="email" data-title="电子邮件" />
                    <input data-field="groupId" data-title="直属单位编号" type="hidden" />
                    <input data-field="group.name" data-title="直属单位" data-popup="SelectGroup" data-popup-parameter="#:#_TemplatePopupParameter_SelectGroup" />
                    <input data-field="password" data-title="用户密码" data-tooltip="true" data-tooltip-title="密码必须包含大小写字母, 数字和特殊字符, 长度不低于8位, 不填将使用默认密码!" placeholder="密码必须包含大小写字母, 数字和特殊字符, 长度不低于8位, 不填将使用默认密码!" type="password" data-icon="fa fa-eye-slash" data-icon-clicked="#:Common.showHidePassword" />
                    <span data-field="state" data-title="状态" required type="radio" data-with-group="true" data-data="#:cache.dataState" data-value="Available"></span>
                    <textarea data-field="description" data-title="备注说明" rows="3" data-multiple="true"></textarea>
                    <input data-field="image" data-title="用户图片" data-with-attachments="true" data-business-type="User.Image" data-single="true" type="file" data-role="kendoUpload" data-file-size="1024" data-file-extension=".jpg,.jpeg,.png" />
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="post"></button>
            <button data-button="put"></button>
            <button data-button="close"></button>
        </div>
    </div>
</div>

<span id="_TemplatePopupParameter_SelectGroup" node="popupParameter" data-title="选择直属单位">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="groupId" data-target="id"></span>
        <span data-transfer="int,out" data-source="group.name" data-target="name"></span>
    </span>
</span>

<partial name="../Popups/SelectGroup" />